<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
</head>

<body>
    <div id="root">
        <h2>{{msg}}</h2>
        <hr>
        <school></school>
        <hr>
        <student></student>
    </div>
</body>
<script>
    Vue.config.productionTip = false //组织vue在启动时生成生产提示

    const school = Vue.extend({
        template: `
        <div class="demo">
					<h2>学校名称：{{schoolName}}</h2>
					<h2>学校地址：{{address}}</h2>
					<button @click="showName">点我提示学校名</button>	
				</div>

        `,
        data() {
            return {
                schoolName: 'VUE',
                address: '北京'
            }
        },
        methods: {
            showName() {
                alert(this.schoolName)
            }
        },
    })

    const student = Vue.extend({
        template: `
                <div> 
					<h2>学生姓名：{{studentName}}</h2>
					<h2>学生年龄：{{age}}</h2>
                    <button @click=showAge()>点击显示年龄</button>
				</div>
                `,
        data() {
            return {
                studentName: "Tom",
                age: '19'
            }
        },
        methods: {
            showAge() {
                alert(this.age)
            }
        },
    })
    new Vue({
        el: '#root',
        data() {
            return {
                msg:'hello'
            }
        },
        components: {
            school,
            student
        }
    })
</script>

</html>